const state = {
	theme: localStorage.getItem('theme'),
	list:'',
	screenWidth:0,
	screenHeight: 0,
	Collapse:false,
	//顶部导航栏的路由
	activeIndex:sessionStorage.getItem('topactiveIndex'),
	//缓存的三级页面路由
	index:sessionStorage.getItem('index'),
	ICPSindex:sessionStorage.getItem('ICPSindex'),
	//要设置的初始属性值
	
};
//实时监听state值的变化(最新状态)
const getters = {
	gettheme(state) { //方法名随意,主要是来承载变化的userinfo的值
		return Number(state.theme)
	},
	getlist(state) { 
		return state.list
	},
	getscreenWidth(state) { 
		return state.screenWidth
	},
	getscreenHeight(state) { 
		return state.screenHeight
	},
	getsCollapse(state) { 
		return state.Collapse
	},
	getactiveIndex(state) { 
		return state.activeIndex
	},
	getindex(state) { 
		return state.index
	},
	getICPSindex(state) {
		return state.ICPSindex
	},
};
//第一参数未默认参数
//同步，执行this.$store.commit('')
const mutations = {
	Changetheme(state, theme) { //自定义改变state初始值的方法，这里面的参数除了state之外还可以再传额外的参数(变量或对象);
		state.theme = theme
		localStorage.setItem('theme', theme);
	},
	Changelist(state, list) { 
		state.list = list
	},
	ChangescreenWidth(state, screenWidth) { 
		state.screenWidth = screenWidth
	},
	ChangescreenHeight(state, screenHeight) {
		state.screenHeight = screenHeight
	},
	ChangeCollapse(state, Collapse) {
		state.Collapse = Collapse
	},
	ChangeactiveIndex(state, activeIndex) { 
		state.activeIndex = activeIndex
	},
	Changeindex(state, index) { 
		state.index = index
	},
	ChangeICPSindex(state, ICPSindex) {
		state.ICPSindex = ICPSindex
	},
};
//异步，执行this.$store.dispatch('')
const actions = {
	Changetheme(context, theme) { //自定义触发mutations里函数的方法，context与store 实例具有相同方法和属性
		context.commit('Changetheme', theme);
	},
	Changelist(context, list) { 
		context.commit('Changelist', list);
	},
	ChangescreenWidth(context, screenWidth) { 
		context.commit('ChangescreenWidth', screenWidth);
	},
	ChangescreenHeight(context, screenHeight) {
		context.commit('ChangescreenHeight', screenHeight);
	},
	ChangeCollapse(context, Collapse) { 
		context.commit('ChangeCollapse', Collapse);
	},
	ChangeactiveIndex(context, activeIndex) {
		sessionStorage.setItem('topactiveIndex',activeIndex)
		context.commit('ChangeactiveIndex', activeIndex);
	},
	Changeindex(context, index) {
		sessionStorage.setItem('index', index);
		context.commit('Changeindex', index);
	},
	ChangeICPSindex(context, ICPSindex) {
		sessionStorage.setItem('ICPSindex', ICPSindex);
		context.commit('ChangeICPSindex', ICPSindex);
	},
};
export default {
	//namespaced:true,//用于在全局引用此文件里的方法时标识这一个的文件名
	state,
	getters,
	mutations,
	actions
}
